home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
vsa256.zip
/
VSA_DEMO.C
< prev
next >
Wrap
C/C++ Source or Header
|
1996-06-01
|
28KB
|
789 lines
/*..........................................................................*/
/* VSA_DEMO.C 5-29-96 */
/* */
/* This is the "C" source code for the VSA_DEMO.EXE program. This program */
/* demonstrates the usage of the VSA256 Graphics Library, Version 4.0. */
/* functions. */
/* */
/* Note: Set STACK SIZE to approx 10000 bytes. */
/* Note: For BORLAND compilers, use -Fs flag (SS = DS)! */
/* */
/* Copyright Spyro Gumas, 1992 - 1996. All Rights Reserved. */
/*..........................................................................*/
#include<dos.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<limits.h>
#include<bios.h>
#include<conio.h>
#include<time.h>
#include <vsa.h> /* Required to support VSA256 Graphics Library */
#include <vsa_font.h> /* Required to support VSA256 Graphics Library */
#include <tiff.h> /* Required to support TIFF256 Graphics Library */
#ifndef _MSC_VER
/*..... This is for Borland C Only ! .....*/
extern unsigned _stklen = 10000;
#endif
void cube(int,int,int);
void cubes(int,int,int);
void rainbow_lut(void);
void shaded_lut(void);
void color_bar(int,int);
void banner(int,int);
void image(int,int);
void obj_3d(int,int);
void cube_3d(int,int);
int any_key(void);
void delay(unsigned);
void color_effect(void);
void vsa_get_input(char *);
void vsa_setup(void);
void blueberry(void);
void flipper(void);
void pgram(int,int,int,int,int,int,int,int);
float SIN_LUT[1024];
void main()
{
int i,k,l,ty,tx,c1,c2,vmode;
unsigned xx,yy,a,b,c,d,m,n,oldm,oldn,image_size;
char your_name[80];
unsigned char *pict1;
float x_scale,y_scale;
/*..........................................................................*/
/* If demo locks up during color cycling, or color mods crash for whatever */
/* reason, set the global parameter VSA_ATI_COLOR = 1. */
/*..........................................................................*/
// VSA_ATI_COLOR = 1;
/*..........................................................................*/
/* Initialize sin look up table. */
/* Index 'i' goes from 0 to 1023 and is equivalent to 0 to 360 degrees. */
/*..........................................................................*/
for(i=0;i<1024;i++)
SIN_LUT[i] = sin(i*6.28/1024.0);
vsa_setup();
vsa_get_svga_mode(&vmode);
rainbow_lut();
/*..........................................................................*/
/* Draw a BlueBerry Name. */
/*..........................................................................*/
blueberry();
/*..........................................................................*/
/* Do a quicky Page Flipping Demo in --- 640x480 mode. */
/*..........................................................................*/
flipper();
/*..........................................................................*/
/* Now switch back to user specified vmode and do rest of demo. */
/*..........................................................................*/
vsa_init(vmode);
rainbow_lut();
xx = XResolution;
yy = YResolution;
x_scale = XResolution/640.0;
y_scale = YResolution/480.0;
vsa_set_text_scale(x_scale,y_scale);
vsa_set_color(0);
vsa_move_to(0,0);
vsa_rect_fill(xx-1,yy-1);
/*..........................................................................*/
/* Draw a frame */
/*..........................................................................*/
vsa_set_color(1);
vsa_move_to(0,0);
vsa_rect(xx-1,yy-1);
c1 = 30;
c2 = 20;
vsa_shaded_triangle(0,0,c1,10,10,c2,10,yy-11,c2);
vsa_shaded_triangle(0,0,c1,0,yy-1,c1,10,yy-11,c2);
vsa_shaded_triangle(0,0,c1,xx-1,0,c1,xx-11,10,c2);
vsa_shaded_triangle(0,0,c1,10,10,c2,xx-11,10,c2);
vsa_shaded_triangle(0,yy-1,c1,10,yy-11,c2,xx-11,yy-11,c2);
vsa_shaded_triangle(0,yy-1,c1,xx-1,yy-1,c1,xx-11,yy-11,c2);
vsa_shaded_triangle(xx-1,0,c1,xx-1,yy-1,c1,xx-11,10,c2);
vsa_shaded_triangle(xx-1,yy-1,c1,xx-11,yy-11,c2,xx-11,10,c2);
/*..........................................................................*/
/* Draw color look up table at bottom of screen. */
/*..........................................................................*/
a = .125*xx;
b = .83*yy;
color_bar(a,b);
/*..........................................................................*/
/* Draw "random" cubes enclosed by rectangle */
/*..........................................................................*/
a = .6*xx;
b = .4*yy;
c = .88*xx;
d = .72*yy;
tx = (a+(c-a)/2) - 12*XCharSize;
ty = d + 0.01*yy;
vsa_write_string(tx,ty,250,"Lines using `vsa_line_to'");
vsa_write_string(tx,ty+YCharSize,64,"Clipping: `vsa_set_viewport'");
vsa_move_to(a,b);
vsa_set_color(180);
vsa_rect(c,d);
vsa_move_to(a+1,b+1);
vsa_set_color(20);
vsa_rect_fill(c-1,d-1);
vsa_set_viewport(a+1,b+1,c-1,d-1);
srand(1);
cubes(a,b,1);
/*..........................................................................*/
/* Draw a banner */
/*..........................................................................*/
vsa_set_viewport(0,0,xx,yy);
a = .55*xx;
b = .06*yy;
banner(a,b);
/*..........................................................................*/
/* Draw 2D sine-cosine image */
/*..........................................................................*/
a = .08*xx;
b = .15*yy;
image(a,b);
/*..........................................................................*/
/* Draw a 3-D shaded object */
/*..........................................................................*/
a = .08*xx;
b = .5*yy;
obj_3d(a,b);
/*..........................................................................*/
/* Draw a 3-D shaded Cube */
/*..........................................................................*/
a = .5*xx;
b = .35*yy;
cube_3d(a,b);
/*..........................................................................*/
/* Using Text Cursor Mode 1. */
/*..........................................................................*/
ty = .05*yy;
tx = .05*xx;
vsa_set_text_cursor_mode(1);
vsa_write_string(tx,ty,250,"Please Enter Your Name: ");
vsa_get_input(your_name);
vsa_set_text_cursor(tx,ty+YCharSize);
vsa_set_text_color(200);
vsa_write_string_alt("Hello ");
vsa_write_string_alt(your_name);
vsa_write_string_alt(", Hit any key to bail.");
/*..........................................................................*/
/* NOTE: TIFF256 requires Large MEM Model if you uncomment following lines! */
/*..........................................................................*/
/*.....
printf("Input Full file name for TIFF file to be saved: ");
scanf("%s",filename);
tf_save_file(0,YResolution-1,XResolution-1,0,filename);
.....*/
/*..........................................................................*/
/* Now do moving clipped cubes effect until someone presses a key. */
/*..........................................................................*/
k = 0;
l = 256;
a = .6*xx;
b = .4*yy;
c = .88*xx;
d = .72*yy;
oldm = a;
oldn = b;
vsa_set_viewport(a+1,b+1,c-1,d-1);
while(!any_key())
{
m = a + xx*0